/**
 * 本类是用来初始化Log4j.
 * 
 */
package bhbt.servlet;

import org.apache.log4j.PropertyConfigurator;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * InitLog.
 * 
 * @author
 * 
 */
public class InitLogServlet extends HttpServlet {

	/**
     * init方法.
     * @throws ServletException ServletException
     */
    public void init() throws ServletException {
        ServletContext sct = getServletContext();
        System.out.println("[Log4j]: The Root Path: " + sct.getRealPath("/"));
        System.out.println("[Log4j]: InitServlet init start...");

        String log4jPath = sct.getRealPath("/") + getServletConfig().getInitParameter("log4j");
        System.out.println("[Log4j]: The Root Path: " + log4jPath);
        PropertyConfigurator.configure(log4jPath);
        System.out.println("[Log4j]: InitServlet init over.");
    }

    /**
     * doGet方法.
     * @param request request
     * @param response response
     * @throws IOException IOException
     * @throws ServletException ServletException
     */
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

    }

    /**
     * doPost方法.
     * @param request request
     * @param response response
     * @throws IOException IOException
     * @throws ServletException ServletException
     */
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

    }
}
